package com.example.mall.common.core.configuration;

import com.example.mall.common.core.AutoPrefixUrlMapping;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@Component
public class AutoPrefixUrlConfiguration implements WebMvcRegistrations {
    @Value("${app.auto-prefix.enable}")
    private Boolean enable; // 是否开启

    @Override
    public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
        if (enable == true) {
            return new AutoPrefixUrlMapping();
        }
        return WebMvcRegistrations.super.getRequestMappingHandlerMapping();
    }
}
